<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("dinocap2", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));


error_reporting(E_ALL ^ E_NOTICE);
 //FUNCTION: Connect to PostgreSql database

set_time_limit(0);
ini_set("memory_limit", "200M");
  pg_connect("host=localhost dbname=comds  user=root  password=root")
   or die('Could not connect:'.pg_last_error());

   $dateTime = date("Y-m-d",strtotime("-1 day"));
    pg_query("delete from comds  a  where date ='$dateTime' and a.id not in (select max(id) from comds b where date ='$dateTime' group by deviceid)");


mysql_close($con);
?>